Skip to content

Python: Allow OpenAI function results without call IDs - #7928

Closed
mikemikimike wants to merge 5 commits into
microsoft:mainfrom
mikemikimike:fix/openai-optional-function-result-call-id
Closed

Python: Allow OpenAI function results without call IDs#7928
mikemikimike wants to merge 5 commits into
microsoft:mainfrom
mikemikimike:fix/openai-optional-function-result-call-id

Conversation

@mikemikimike

@mikemikimike mikemikimike commented Aug 28, 2026

Copy link
Copy Markdown

Motivation & Context

The OpenAI Responses API permits function_call_output items without a call_id, but Agent Framework currently requires one when constructing function-result content and serializes an absent value as "call_id": null. This makes adapting OpenAI-compatible SDK payloads unnecessarily difficult.

Description & Review Guide

  • What are the major changes? Content.from_function_result now accepts an omitted call ID, and the OpenAI Responses serializer only includes call_id when one is provided.
  • What is the impact of these changes? Function results without IDs can be represented and sent without a null field; existing function results with IDs retain their current payload.
  • What do you want reviewers to focus on? Please review the optional-field boundary and the unchanged ID-preserving path. The function-calling specification matrix now names this provider scenario and links it to the regression test in packages/openai/tests/openai/test_openai_chat_client.py.
  • Local checks: The OpenAI package's non-integration test suite passes, focused core factory tests pass, Ruff 0.16.3 checks pass, targeted Pyright passes for both changed source files, and both affected packages build successfully.
  • Known environment limitation: The full core test and standard dependency type-checking sweeps require optional mcp, agent-hooks, and related workspace packages that are not installed in this checkout.
  • Review status: This pull request remains a draft for maintainer confirmation of the function-calling contract.

Related Issue

Fixes #7922

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible (the focused core tests and full OpenAI package suite pass; the full core sweep is limited by optional workspace dependencies noted above)
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Allows OpenAI Responses API function results to omit call_id instead of serializing it as null.

Changes:

  • Makes Content.from_function_result accept an optional call ID.
  • Conditionally serializes call_id.
  • Adds regression tests for ID-less results.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
python/packages/core/agent_framework/_types.py Makes result call IDs optional.
python/packages/core/tests/core/test_types.py Tests ID-less result construction.
python/packages/openai/agent_framework_openai/_chat_client.py Omits absent IDs from Responses payloads.
python/packages/openai/tests/openai/test_openai_chat_client.py Tests serialization with no call ID.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread python/packages/openai/tests/openai/test_openai_chat_client.py
@mikemikimike
mikemikimike deployed to github-app-auth September 3, 2026 17:02 — with GitHub Actions Active

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Maintainer confirmation of the function-calling contract and final human review are still warranted.

Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@eavanvalkenburg

Copy link
Copy Markdown
Member

This is now handled differently because of a previously merged PR (#7988), please check if that does not overlap here. mikemikimike

@eavanvalkenburg

Copy link
Copy Markdown
Member

Closing this PR rather than merging it because #7988 established a different core identity contract:

  • Content.id identifies one Agent Framework call occurrence.
  • call_id remains the provider/service correlation key between a function call and its result.
  • Actionable local calls that arrive without a provider ID receive a safe effective correlation ID before execution, so locally produced results remain paired.

Making Content.from_function_result(..., call_id=None) generally valid would weaken that provider-neutral contract and permit orphan results through invocation, approvals, history, compaction, and non-OpenAI adapters. The OpenAI create schema now documents function_call_output.call_id as optional, but the currently supported OpenAI SDK request type still requires it, as do .NET MEAI's FunctionResultContent and .NET AF's Responses models. The newer OpenAI shape also carries possible alternate identity/context fields (caller, name, namespace, and item id) that this PR does not model.

Issue #7922 remains open for a Responses-specific redesign. That work should first establish which id-less wire combinations the service accepts, then represent those fields at the Responses boundary without making anonymous function results executable or generally valid in Agent Framework core. The scenario row added here should be designed with that complete contract rather than merged as an isolated exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: OpenAI RAPI no longer requires the call id on a function call result

3 participants